Here is restaurant data in NYC
---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
```
Here is restaurant data in NYC
```{r}
data(rest_inspec)
rest_inspec_mod =
rest_inspec %>%
select(dba, boro, street, cuisine_description, inspection_type, zipcode, score, grade) %>%
filter(
boro == "MANHATTAN",
inspection_type == "Cycle Inspection / Initial Inspection",
cuisine_description %in% c("American", "French", "Irish", "Italian", "Mexican", "Turkish", "Chinese", "Indian", "Japanese", "Korean", "Latin", "Spanish", "Thai")
) %>%
distinct() %>%
drop_na()
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
rest_inspec_scatt =
rest_inspec_mod %>%
mutate(
text_label = str_c("Cuisine_type: ", cuisine_description, "\nGrade: ", grade)
) %>%
plot_ly(
x = ~zipcode, y = ~street, type = "scatter", mode = "markers", color = ~score, text = ~text_label, alpha = .5
)
rest_inspec_scatt
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
rest_inspec_box =
rest_inspec_mod %>%
mutate(
cuisine_description = fct_reorder(cuisine_description, score)
) %>%
plot_ly(y = ~score, color = ~cuisine_description, type = "box",
colors = "viridis")
rest_inspec_box
```
### Chart C
```{r}
rest_inspec_bar =
rest_inspec_mod %>%
count(cuisine_description) %>%
mutate(cuisine_description = fct_reorder(cuisine_description, n)) %>%
plot_ly(x = ~cuisine_description, y = ~n, color = ~cuisine_description, type = "bar", colors = "viridis")
rest_inspec_bar
```